/*
 * ClearButtonListener
 * 
 * Version information:1.0
 *
 * Date: 19/11/2012
 */
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JTextArea;

/**
 * @author dv11rlm
 */
public class ClearButtonListener implements ActionListener {

    /*
     * The reference to a textArea we wish to clear whenever we an
     * action is performed on.
     */
    private JTextArea textArea;

    /**
     * Store reference to textArea so that we can perform changes
     * whenever a event is invoked.
     * 
     * @param textArea
     */
    public ClearButtonListener(JTextArea textArea) {
	if (textArea == null) {
	    throw new NullPointerException("textArea null");
	}
	this.textArea = textArea;
    }

    /**
     * Function will clear the previously given JTextArea.
     * 
     * @see ClearButtonListener, JTextArea
     */
    @Override
    public void actionPerformed(ActionEvent arg0) {
	textArea.setText("");
    }
}
